package com.example.lol.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.adapter.NewsAdapter2;
import com.example.lol.ui.adapter.NewsAdapter3;
import com.example.lol.ui.bean.NewBean;
import com.example.lol.ui.bean.NewBean2;

import java.util.ArrayList;
import java.util.List;

public class ThirdHomeFragment extends Fragment {
    private String[] title = new String[]{"          小蜜蜂宝典现已上线可前往客户端参与活动",
            "福牛杯专题：百万现金冠军独享！",
            "每日一笑：好硬核的请假理由",
            "掌盟戏精王：还在为事情太多而焦虑吗？",
            "其软怕硬的369！打TheShy选石头人 BiuBiu就奎因"
    };
    private String[] title1 = new String[]{" 英雄联盟官方赛事 ",
            "掌小萌",
            "掌盟每日一笑",
            "掌盟戏精王",
            "盲仔看电竞"
    };
    private int[] cover = new int[]{R.drawable.ic_xmf,
            R.drawable.ic_fnb,
            R.drawable.ic_hl,
            R.drawable.ic_gdjl,
            R.drawable.ic_369};
    private String[] number = new String[]{"5","133","2","22","67"};
    private List<NewBean2> initData() {
        List<NewBean2> list = new ArrayList<>();
        list.add(new NewBean2());
        list.add(new NewBean2(title[0],title1[0],cover[0],R.drawable.ic_lol4,R.drawable.ic_chat,number[0],3));
        for (int i=1;i<5;i++){
            list.add(new NewBean2(title[i % title.length],title1[i % title1.length],cover[i % cover.length],R.drawable.ic_lol4,R.drawable.ic_chat,number[i %number.length],2));
        }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.recycle, container, false);
        RecyclerView textView = view.findViewById(R.id.recycle_ss);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        NewsAdapter3 newsAdapter=new NewsAdapter3(initData());
        newsAdapter.setList(initData());
        textView.setAdapter(newsAdapter);
        return view;
    }
}
